-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ts_package extension #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, was very busy last week. So this is more like an alias proto then we could point the import from an existing npm package of other generated code.
This is cool, thanks for your contribution.
Also a question to you, I prefer to see a test for this feature. Is there any good generated package you know that we could import for a test purpose?
registry/registry.go
Outdated
if os.IsNotExist(err) { | ||
return false, nil | ||
if pkg, ok := r.TSPackages[target]; ok { | ||
log.Debugf("pkg: %s", pkg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a better debug message? saying package import override %s has been found for file%s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review. I will fix this ASAP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyonlai I fixed the debug message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think google-protobuf package is good for testing. I try to write a test. Please wait for a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyonlai I added integration test for ts_package option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice.
9d7c29d
to
442b0bb
Compare
integration_tests/package.json
Outdated
@@ -25,5 +26,8 @@ | |||
"mocha": "^8.2.0", | |||
"ramda": "^0.27.1", | |||
"typescript": "^4.0.5" | |||
}, | |||
"dependencies": { | |||
"google-protobuf": "^3.15.8" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this also be a devDependencies
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I fixed this.
9874c67
to
aa44457
Compare
Thank you very much for you contribution. |
would you mind to squash the commit into 1 before merge? @higebu |
aa44457
to
885a25e
Compare
@lyonlai Done! |
thank you, will merge once test finished green |
This PR adds the
grpc.gateway.protoc_gen_grpc_gateway_ts.options.ts_package
option to specify the package name of proto files.For example, we can add following lines to
google/protobuf/empty.proto
with package name "google-protobuf/google/protobuf/empty_pb".Then we can use @types/google-protobuf package for
google.protobuf.Empty
.Related to: protocolbuffers/protobuf-javascript#47